package com.hzvdvmc.autosale.socket.manager;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created by william on 2018/4/21.
 */

public class SocketRequestQuence {

    private static List<SocketRequest> quenceList = new CopyOnWriteArrayList<>();
    private static SocketRequest[] requests = new SocketRequest[10];

    public static void onReceivedData(String cmd, String data) {
        for (SocketRequest quence : quenceList) {
            quence.callBack(cmd, data);
        }
    }

    public static void addQuence(SocketRequest request) {

        if (quenceList.size() > 10) {
            quenceList.remove(0);
        }

        quenceList.add(request);
    }

    public static void clearQuence(){
        quenceList.clear();
    }


}
